Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contracts: feature: introduce realm levels #1721

Merged
merged 17 commits into from
Oct 8, 2024
Merged

contracts: feature: introduce realm levels #1721

merged 17 commits into from
Oct 8, 2024

Conversation

credence0x
Copy link
Collaborator

contracts for #1719

  • introduce realm levels
  • create a function for upgrading realm levels as well as functions for configuration
  • restrict building on certain hexes depending on realm level
  • tests

Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2024 9:05am

Copy link

Failed to generate code suggestions for PR

Copy link
Contributor

@mentatbot mentatbot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation of realm levels looks solid and well-integrated with existing systems. The new functionality includes a level field in the Realm struct, a RealmLevelConfig for storing level-up requirements, and an upgrade_level function in the realm systems contract. The building creation process now checks the realm's level before allowing placement, which is a good way to enforce level restrictions.

The tests are comprehensive and cover various scenarios, including successful upgrades, insufficient resources, and attempts to upgrade beyond the max level. The max level is currently hardcoded to 3, which might be worth reconsidering for future flexibility.

Overall, the changes seem well-thought-out and follow established patterns in the codebase. Consider adding more documentation for the realm level mechanics and possibly emitting events for level upgrades to improve observability.

Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!

impl RealmCustomImpl of RealmCustomTrait {
fn max_level(self: Realm) -> u8 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making the max_level configurable rather than hardcoded. This would allow for easier adjustments in the future if needed.

@@ -178,5 +180,42 @@ mod realm_systems {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider emitting an event when a realm is upgraded. This would be useful for tracking realm progress and could be used by the frontend or other systems.

Suggested change

let directions_count = directions.len();
assert!(directions_count > 0, "building cant be made at the center");
assert!(directions_count <= realm.max_level().into() + 1, "building outside of max bound");
assert!(directions_count <= realm.level.into() + 1, "building outside of what realm level allows");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'building outside of what realm level allows' could be more informative. Consider including the current realm level and the required level in the message.

Suggested change
assert!(directions_count <= realm.level.into() + 1, "building outside of what realm level allows");
assert!(directions_count <= realm.level.into() + 1,
&format!("building outside of what realm level allows: current level is {}, required level is {}", realm.level, directions_count - 1));

impl RealmCustomImpl of RealmCustomTrait {
fn max_level(self: Realm) -> u8 {
3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to config

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

@ponderingdemocritus ponderingdemocritus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smol config change

@ponderingdemocritus ponderingdemocritus changed the base branch from main to rc October 1, 2024 23:39
@ponderingdemocritus
Copy link
Contributor

In config i have added some contants which can be used to init the config, can you update to use them

@credence0x credence0x merged commit 4752f4c into rc Oct 8, 2024
21 of 23 checks passed
@credence0x credence0x deleted the realm-level branch October 8, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants